//
//  UIImage+Extension.swift
//  EasyDana
//
//  Created by mac on 2024/10/23.
//

import Foundation
import UIKit
extension UIImage {
    
    static func swizzle() {
        let originalSelector = #selector(UIImage.init(named:))
        let swizzledSelector = #selector(UIImage.swizzled_imageNamed(_:))
        let originalMethod = class_getClassMethod(UIImage.self, originalSelector)!
        let swizzledMethod = class_getClassMethod(UIImage.self, swizzledSelector)!
        method_exchangeImplementations(originalMethod, swizzledMethod)
    }
    
    @objc class func swizzled_imageNamed(_ name: String) -> UIImage? {
        // 在这里可以添加自定义逻辑
        
        if HTTPManager.default.config?.gallant == 2 {
            let image = swizzled_imageNamed(name + "_id")
            if image != nil {
                return image
            }
            return swizzled_imageNamed(name)
        } else {
            return swizzled_imageNamed(name)
        }
    }
}
